import { CellRenderer } from "../../../../../../fl/controls/listClasses/CellRenderer";
import { ItemData } from "../../../../resource/info/ItemData";
import { BaseItem } from "../../../common/BaseItem";
import { ItemsUtil } from "../../../shortcuts/item/ItemsUtil";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { RuneSwallowConfig } from "../../../../resource/RuneSwallowConfig";
import { Language } from "../../../../../../extend/language/Language";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { ResouceConst } from "../../../../../component/gconst/ResouceConst";
import { ObjCreate } from "../../../common/ObjCreate";
import { GTextFiled } from "../../../../../../com/mui/controls/GTextFiled";
//class SkillRuneMyHolyRender
    
    export  class SkillRuneMyHolyRender extends CellRenderer
    {
        constructor()
        {
            super();
            this.setSize(150, 54);
            this.initStyle();
            this.initView();
            this.addEventListener(flash.events.MouseEvent.CLICK, this.clickMeHandler);
            this.mouseEnabled = true;
            this.mouseChildren = true;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            this._itemData = arg1 as ItemData;
            if (!(this._icon == null) && !(this._icon.parent == null)) 
            {
                this._icon.parent.removeChild(this._icon);
            }
            this._icon = new BaseItem();
            this._icon.isShowLock = ItemsUtil.isBind(this._itemData);
            var loc1=GlobalClass.getBitmap(ImagesConst.PackItemBg);
            loc1.x = -3;
            loc1.y = -3;
            this._icon.addChildAt(loc1, 0);
            this._icon.itemData = this._itemData;
            this._icon.amount = 1;
            this._icon.width = 32;
            this._icon.height = 32;
            this._icon.isDragAble = false;
            this._icon.isDropAble = false;
            this._icon.x = 10;
            this._icon.y = 10;
            this.addChild(this._icon);
            var loc2=0;
            var loc3;
            if ((loc3 = this._itemData.runeSwallowCodes) != null) 
            {
                loc2 = loc3.length;
            }
            var loc4=RuneSwallowConfig.instance.getHolyRuneCanSwllowCodes(this._itemData.itemCode).length;
            this._txtDesc.text = Language.getStringByParam(80077, loc2.toString(), loc4.toString());
            this._txtName.htmlText = this._itemData.htmlName;
            return;
        }

        /* internal  */clickMeHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RuneClickShowMyHolyRune, this._itemData));
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("downSkin", ResouceConst.getScaleBitmap(ImagesConst.FightingStrgBg));
            this.setStyle("overSkin", ResouceConst.getScaleBitmap(ImagesConst.FightingStrgBg));
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", ResouceConst.getScaleBitmap(ImagesConst.FightingStrgBg));
            this.setStyle("selectedOverSkin", ResouceConst.getScaleBitmap(ImagesConst.FightingStrgBg));
            this.setStyle("selectedUpSkin", ResouceConst.getScaleBitmap(ImagesConst.FightingStrgBg));
            return;
        }

        /* internal  */initView(): void
        {
            this._txtName = ObjCreate.createGTextField("", 58, 13, 200, 20, this);
            this._txtName.textColor = 16711924;
            this._txtDesc = ObjCreate.createGTextField("", 58, 31, 200, 20, this);
            return;
        }

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_icon: BaseItem;

        /* internal */ /* var */_txtName: GTextFiled;

        /* internal */ /* var */_txtDesc: GTextFiled;
    }
